//
//  TWorkSelectedTopView.m
//  SanYiTeaching
//
//  Created by 李文强 on 2019/4/9.
//  Copyright © 2019 李文强. All rights reserved.
//

#import "TWorkSelectedTopView.h"

@implementation TWorkSelectedTopView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (instancetype)initWithFrame:(CGRect)frame{
    if ([super initWithFrame:frame]) {
        [self initSubView];
    }
    return self;
}
- (void)initSubView{
    [self addSubview:self.title];
    self.backgroundColor = MAINBACKCOLOR;
    [_title mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX).offset(-50);
        make.centerY.equalTo(self.mas_centerY);
        make.width.equalTo(@100);
        make.height.equalTo(@40);
    }];
    
    [self addSubview:self.timeButton];
    [self addSubview:self.nianjiButton];
//    [self addSubview:self.addButton];
    [_timeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_right).offset(-230);
        make.centerY.equalTo(self.mas_centerY);
        make.width.equalTo(@100);
        make.height.equalTo(@20);
    }];
//    [_addButton mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.right.equalTo(self.timeButton.mas_left).offset(-20);
//        make.centerY.equalTo(self.timeButton.mas_centerY);
//        make.width.equalTo(@20);
//        make.height.equalTo(@20);
//    }];
    [_nianjiButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.timeButton.mas_right).offset(5*fw);
        make.centerY.equalTo(self.mas_centerY);
        make.width.equalTo(@100);
        make.height.equalTo(@20);
    }];
}
- (UILabel *)title{
    if (!_title) {
        UILabel *label = [[UILabel alloc]init];
        label.text = @"结果统计";
        label.textColor = [UIColorChange colorwithHexString:@"#20B097"];
        _title = label;
    }
    return _title;
}
- (UIButton *)addButton{
    if (!_addButton) {
        UIButton *sender = [UIButton buttonWithType:UIButtonTypeCustom];
        [sender setBackgroundImage:[UIImage imageNamed:@"add_teach"] forState:UIControlStateNormal];
        [sender addTarget:self action:@selector(addClick:) forControlEvents:UIControlEventTouchUpInside];
        _addButton = sender;
    }
    return _addButton;
}
- (void)addClick:(UIButton *)sender{
    
}
- (MinButtonViewBtn *)timeButton{
    if (!_timeButton) {
        MinButtonViewBtn *btn = [[MinButtonViewBtn alloc]initWithFrame:CGRectMake(550*fw, 15, 100, 20) andType:ButtonImageInRight];
        btn.bottomLabel.text = @"选择测试类型";
        btn.bottomLabel.font = [UIFont systemFontOfSize:12];
        btn.bottomLabel.textColor = TITLECOLOR;
        btn.topImage.image = [UIImage imageNamed:@"arrow_down"];
        [btn addTarget:self action:@selector(timeClick:) forControlEvents:UIControlEventTouchUpInside];
        [btn.bottomLabel mas_updateConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@0);
            make.right.equalTo(@0).offset(-15);
        }];
        _timeButton = btn;
    }
    return _timeButton;
}
- (void)timeClick:(MinButtonViewBtn *)sender{
    [self.delegate leftWorkButtonClick];
}
- (MinButtonViewBtn *)nianjiButton{
    if (!_nianjiButton) {
        MinButtonViewBtn *btn = [[MinButtonViewBtn alloc]initWithFrame:CGRectMake(550*fw, 15, 69, 20) andType:ButtonImageInRight];
        btn.bottomLabel.text = @"选择班级";
        btn.bottomLabel.font = [UIFont systemFontOfSize:12];
        btn.bottomLabel.textColor = TITLECOLOR;
        btn.topImage.image = [UIImage imageNamed:@"arrow_down"];
        [btn addTarget:self action:@selector(nianjiButton:) forControlEvents:UIControlEventTouchUpInside];
        [btn.bottomLabel mas_updateConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@0);
            make.right.equalTo(@0).offset(-15);
        }];
        _nianjiButton = btn;
    }
    return _nianjiButton;
}
- (void)nianjiButton:(MinButtonViewBtn *)sender{
    [self.delegate rightWorkButtonClick];
}
@end
